{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PHCv2.4.86 released 2022-05-30 works!\n"
     ]
    }
   ],
   "source": [
    "import c_solver_2D as csolver"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy import io as sio"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Test beta dependent spectrum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "Jx1 = 1\n",
    "Jx2 = 2\n",
    "Jy1 = 0.9j\n",
    "Jy2 = 0.9j"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "beta1 = np.exp(1j * np.linspace(0, 2*np.pi, 100))\n",
    "phi20 = np.pi/3\n",
    "E1 = np.cos(phi20/2) * np.sqrt((Jx2 * beta1 + Jy1) * (Jx1 / beta1 + Jy2))\n",
    "E2 = - E1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.plot(E1.real, E1.imag, '.')\n",
    "plt.plot(E2.real, E2.imag, '.')\n",
    "E0 = np.cos(phi20/2) * np.sqrt((Jx2 * beta1[0] + Jy1) * (Jx1 / beta1[0] + Jy2))\n",
    "plt.plot(E0.real, E0.imag, 'rx')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using matplotlib backend: QtAgg\n"
     ]
    }
   ],
   "source": [
    "%matplotlib"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "beta1 = np.exp(1j * np.linspace(0, 2*np.pi, 100))\n",
    "plt.clf()\n",
    "for phi2 in np.linspace(0, np.pi, 100):\n",
    "    E1 = np.cos(phi2/2) * np.sqrt((Jx2 * beta1 + Jy1) * (Jx1 / beta1 + Jy2))\n",
    "    E2 = - E1\n",
    "    plt.plot(E1.real, E1.imag, '.')\n",
    "    plt.plot(E2.real, E2.imag, '.')\n",
    "    plt.plot(E0.real, E0.imag, 'rx')\n",
    "    plt.pause(0.1)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# NH SSH"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "poly_data = sio.loadmat(\"data/GBZ_char_poly_2.mat\")\n",
    "coeffs = poly_data['coeffs'].flatten()\n",
    "degrees = poly_data['orders'].flatten()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "char_poly = csolver.CLaurant(3)\n",
    "char_poly.set_Laurant_by_terms(csolver.CScalarVec(coeffs), csolver.CIntVec(degrees))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.16"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
